import request from '@/utils/request.js'

/**
 *获取频道新闻列表
 * @param {*}   params    channel_id timestamp with_top
 *
 */
export function getArticleList (params) {
  return request({
    url: '/v1_1/articles',
    params
  })
}

/**
 * 获取所有频道列表
 * @returns
 */
export function allArticle () {
  return request({
    url: '/v1_0/channels'
  })
}

/**
 * 获取文章详情
 * @returns
 */
export function getArticleDetail (id) {
  return request({
    url: '/v1_0/articles/' + id
  })
}

/**
 * 添加收藏
 * @returns target 要收藏的文章id
 */
export function addCollectArticle (target) {
  return request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 取消收藏
 * @returns target 要取消收藏的文章id
 */
export function deleteCollectArticle (target) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}

/**
 * 获取评论列表
 * @returns target 要取消收藏的文章id
 */
export function getCommentList (params) {
  return request({
    url: '/v1_0/comments',
    method: 'GET',
    params
  })
}

/**
 * 发布评论
 * @returns target
 */
export function postComment (data) {
  return request({
    url: '/v1_0/comments',
    method: 'POST',
    data
  })
}
